package com.seuic.posdsdk.device_interface;

import android.graphics.Bitmap;
import android.os.Bundle;

public interface ReceiptEngine extends BaseInterface {
    /**
     * Clear buffer of receipt engine
     *
     * @return 0 to success, other to failed
     */
    int clearBuffer();

    /**
     * Append a line of text to the recept engine
     *
     * @param text The text to append
     * @param params Bundle of parameters
     *               @see com.seuic.constants.ReceiptConstants
     *				FONT_SIZE(int), font size, default: 24
     *				FONT_HEIGHT(int), font height，default: same as font height
     *				ALIGN(String), text align: ALIGN_LEFT(default)
     *									       ALIGN_RIGHT
     *									       ALIGN_CENTER
     *				OFFSET(int), offset of text, default 0
     *				XSPACE(int), horizantal margin between characters, default 0
     *				YSPACE(int), vertical margin between lines,default: 5
     *				IS_BOLD(boolean), whether to use bold font, default: false
     *				IS_ITALIC(boolean), whether to use italic font, default: false
     *				IS_UNDERLINE(boolean), whether to add underline, default: false
     * @return 0 to success, other to failed
     */
    int addTextLine(String text, Bundle params);

    /**
     * Append a bitmap to the recept engine
     *
     * @param bitmap The bitmap to append
     * @param params Bundle of parameters
     *               @see com.seuic.constants.ReceiptConstants
     *				IMAGE_WIDTH(int), image width，default: the width of bitmap
     *				IMAGE_HEIGHT(int)，image height, default: the height of bitmap
     *				ALIGN(String), bitmap align: ALIGN_LEFT
     *			                                 ALIGN_RIGHT
     *			                                 ALIGN_CENTER(default)
     *				OFFSET(int), offset of bitmap, default 0
     *				YSPACE(int), vertical margin between lines,default: 5
     * @return 0 to success, other to failed
     */
    int addBitmap(Bitmap bitmap, Bundle params);

    /**
     * Append QR code to the recept engine
     *
     * @param content The content of QR code
     * @param params Bundle of parameters
     *               @see com.seuic.constants.ReceiptConstants
     *				 QR_LEVEL(int), the level of QR code image, 0~3, default: 0
     *				 QR_SIZE(int), the size of QR code image, default: 225
     *				ALIGN(String), QR code image align: ALIGN_LEFT
     *			                                        ALIGN_RIGHT
     *			                                        ALIGN_CENTER(default)
     *				OFFSET(int), offset of QR code image, default 0
     *				YSPACE(int), vertical margin between lines,default: 5
     * @return 0 to success, other to failed
     */
    int addQRCode(String content, Bundle params);

    /**
     * Append Bar code to the recept engine
     *
     * @param content The content of Bar code
     * @param params Bundle of parameters
     *               @see com.seuic.constants.ReceiptConstants
     *				 BAR_CODE_PX(int), The width of Bar code image, default: 2
     *				 BAR_CODE_HEIGHT(int), The height of Bar code image, default: 90
     *				ALIGN(String), QR code image align: ALIGN_LEFT
     *			                                        ALIGN_RIGHT
     *			                                        ALIGN_CENTER(default)
     *				OFFSET(int), offset of Bar code image, default 0
     *				YSPACE(int), vertical margin between lines,default: 5
     * @return 0 to success, other to failed
     */
    int addBarcode(String content, Bundle params);

    /**
     * Use data in the buffer to generate a receipt bitmap
     *
     * @return The generated bitmap
     */
    Bitmap getReceipt();

    /**
     * Print contents in the buffer
     * When Called, the print process will be started
     * The events and result of the process will be returned in callbacks
     * @see PrintReceiptCallback
     *
     * @param printReceiptCallback
     */
    void print(PrintReceiptCallback printReceiptCallback);

    /**
     * The callback of print receipt process
     */
    interface PrintReceiptCallback {
        /**
         * The print receipt process complete successfully
         */
        void onSuccess();

        /**
         * The print process failed
         *
         * @param error The error description
         */
        void onFail(String error);
    }
}
